#include <stdio.h>
#include <string.h>
#include "reporting.h"


static int _errorcode = REPORTING_NO_ERROR;
static char _errormsg[1000];

void reporting_report(int ec, const char * message)
{
	if (ec != REPORTING_NO_ERROR) {
		_errorcode = ec;
	}
	strncpy(_errormsg, message, sizeof(_errormsg));
	#ifdef REPORTING_WITH_MESSAGE
	fprintf(stderr, "!! %s\n", message);
	#endif
}

void reporting_clear(void)
{
	_errorcode = REPORTING_NO_ERROR;
}

int reporting_get(void)
{
	return _errorcode;
}

const char * reporting_get_message(void)
{
	return _errormsg;
}

int reporting_is_error(int ec)
{
	return ec != REPORTING_NO_ERROR;
}



